package edu.spbu.eclipse.xmledit.andrpodk.editors;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.action.IMenuManager;
import org.eclipse.jface.action.MenuManager;
import org.eclipse.jface.action.Separator;
import org.eclipse.ui.texteditor.BasicTextEditorActionContributor;

public class XMLEditorActionContributor extends BasicTextEditorActionContributor{
	private Action checkForSyntax;
	private Action toHTMLAction;
	private Action checkForSyntaxAndValidate;
	private Action toPDFAction;

	public XMLEditorActionContributor(){
		super();
		checkForSyntax=new Action("Check For Syntax"){
			public void run(){
				((XMLEditor)getActiveEditorPart()).getXsltManager().
				performCheckForSyntaxAction();				
			}			
		};
		toHTMLAction=new Action("Transform To HTML"){
			public void run(){
				((XMLEditor)getActiveEditorPart()).getXsltManager().performToHtmlAction();
			}			
		};
		toPDFAction=new Action("Transform To PDF"){
			public void run(){

			}						
		};
		checkForSyntaxAndValidate=new Action("Check For Syntax And Validate"){
			public void run(){
				((XMLEditor)getActiveEditorPart()).getXsltManager().
				performCheckForSyntaxAndValidateAction();
			}	
		};
	}
	public void contributeToMenu(IMenuManager menuManager){
		super.contributeToMenu(menuManager);
		MenuManager xmlEditorMenu=new MenuManager("XML Editor");		
		menuManager.insertAfter("additions", xmlEditorMenu);
		MenuManager docBookMenu = new MenuManager("DocBook");
		docBookMenu.add(toHTMLAction);
		docBookMenu.add(toPDFAction);
		docBookMenu.add(new Separator());
		docBookMenu.add(checkForSyntaxAndValidate);
		xmlEditorMenu.add(docBookMenu);		
		xmlEditorMenu.add(new Separator());
		xmlEditorMenu.add(checkForSyntax);
	}	
}
